﻿using System.Runtime.Serialization;
using GMME.Model.Rtm.Notify;
using UnityEngine;
using UnityEngine.Scripting;

namespace GMME.Model.Rtm.Result
{
    [DataContract]
    [Preserve]
    public class ReceiveRtmPeerMessageNotify : RtmMessageNotify
    {
#if UNITY_ANDROID
        internal static ReceiveRtmPeerMessageNotify ConvertReceiveRtmPeerMessageNotify(
            AndroidJavaObject javaObject)
        {
            if (javaObject != null)
            {
                ReceiveRtmPeerMessageNotify receiveRtmPeerMessageNotify = new();
                receiveRtmPeerMessageNotify.ServerMsgId = javaObject.Call<string>("getServerMsgId");
                receiveRtmPeerMessageNotify.ClientMsgId = javaObject.Call<string>("getClientMsgId");
                receiveRtmPeerMessageNotify.Timestamp = javaObject.Call<long>("getTimestamp");
                receiveRtmPeerMessageNotify.SenderId = javaObject.Call<string>("getSenderId");
                receiveRtmPeerMessageNotify.IsFromOpenApi = javaObject.Call<bool>("isFromOpenApi");


                receiveRtmPeerMessageNotify.MessageType = javaObject.Call<int>("getMessageType");
                receiveRtmPeerMessageNotify.MessageString = javaObject.Call<string>("getMessageString");
                receiveRtmPeerMessageNotify.MessageBytes = javaObject.Call<byte[]>("getMessageBytes");

                return receiveRtmPeerMessageNotify;
            }

            return null;
        }

#endif
    }
}